#ifndef Invariant_First
#define Invariant_First
#ifdef __GNUG__
#pragma interface
#endif

#include "Types.h"
#include "Error.h"

#ifdef NO_INVCHECK
#   define InvariantChecker(name)
#   define AssertInvariant(name)
#   define Assert(expr)

#else

#   define InvariantChecker(name) \
	class _NAME2_(name,InvChecker) { \
		name *obj; \
	public: \
		_NAME2_(name,InvChecker)(name *o) : obj(o) \
			{  obj->CheckInvariant(); } \
		~_NAME2_(name,InvChecker)() \
			{  obj->CheckInvariant(); } \
		void Use() \
			{ } \
	}

#   define AssertInvariant(name) \
	_NAME2_(name,InvChecker) __checkInv(this); __checkInv.Use()

	extern const char *cAssertMsg;

#   define Assert(e) \
	((e) ? 1 : (Fatal("", cAssertMsg, _QUOTE_(e), __LINE__, __FILE__), 0))

#endif /* NO_INVCHECK */

#endif

